home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Kit PC World De Ampliacion De Windows 95
/
Kit PC World de ampliacion de Windows 95.iso
/
clarion
/
cw15
/
examp15.z
/
DOMIN.CLW
< prev
next >
Wrap
Text File
|
1995-09-05
|
22KB
|
724 lines
! DOMIN: A simple windows game
! ============================
! NB This program is not written with style in mind, as it is
! only intended as a demonstration OF some OF the capabilities
! OF the CW system
PROGRAM
INCLUDE('EQUATES.CLW')
INCLUDE('KEYCODES.CLW')
MAP
showp(BYTE,BYTE)
init()
asknewgame(),BYTE
gameover()
setsize()
setcursors()
getoptions()
addc(BYTE,BYTE,BYTE)
capacity(BYTE,BYTE),BYTE
canadd(BYTE,BYTE,BYTE),BYTE
positional(*BYTE,*BYTE,BYTE)
locate_target(BYTE),BYTE
aboutbox()
END
maxwidth EQUATE (12)
boardwidth STRING(10),AUTO
width SHORT,AUTO
t BYTE,DIM(maxwidth),dim(maxwidth),AUTO
xp BYTE,AUTO
yp BYTE,AUTO
gameinprogress BYTE
nplaying BYTE
nextgo BYTE
mplayers EQUATE(4)
wp BYTE,DIM(mplayers),AUTO
scores LONG,DIM(mplayers),AUTO
playname STRING(12),DIM(mplayers),AUTO
counts USHORT,DIM(4),AUTO
SHuman EQUATE(1)
SDefence EQUATE(2)
SHomicidal EQUATE(3)
SRegicidal EQUATE(4)
SDrifter EQUATE(5)
scr WINDOW('Domination'),AT(,,120,120),CENTER,ICON('WINPYR.ICO'),HLP('~Domination'),STATUS,SYSTEM
MENUBAR
MENU('&File'),MSG('File menu')
ITEM('E&xit'),USE(?exit,5000),MSG('End this game')
END
MENU('&Game'),MSG('Game menu')
ITEM('&New<9>F2'),USE(?new),MSG('Start a new game'),KEY(F2Key)
ITEM('&Options...'),USE(?options),HLP('~Options'),MSG('Select players ...')
END
MENU('&Help'),MSG('Help menu')
ITEM('&Contents'),USE(?helpcontents),MSG('Start a new game'),KEY(F2Key)
ITEM,SEPARATOR
ITEM('&About...'),USE(?about),MSG('About Domination')
END
END
BUTTON,AT(30,10,10,10),KEY(Alt0),USE(?but11,1)
BUTTON,AT(40,10,10,10),USE(?but12)
BUTTON,AT(50,10,10,10),USE(?but13)
BUTTON,AT(60,10,10,10),USE(?but14)
BUTTON,AT(70,10,10,10),USE(?but15)
BUTTON,AT(80,10,10,10),USE(?but16)
BUTTON,AT(90,10,10,10),USE(?but17)
BUTTON,AT(100,10,10,10),USE(?but18)
BUTTON,AT(110,10,10,10),USE(?but19)
BUTTON,AT(120,10,10,10),USE(?but1a)
BUTTON,AT(130,10,10,10),USE(?but1b)
BUTTON,AT(140,10,10,10),USE(?but1c)
BUTTON,AT(30,20,10,10),USE(?but21)
BUTTON,AT(40,20,10,10),USE(?but22)
BUTTON,AT(50,20,10,10),USE(?but23)
BUTTON,AT(60,20,10,10),USE(?but24)
BUTTON,AT(70,20,10,10),USE(?but25)
BUTTON,AT(80,20,10,10),USE(?but26)
BUTTON,AT(90,20,10,10),USE(?but27)
BUTTON,AT(100,20,10,10),USE(?but28)
BUTTON,AT(110,20,10,10),USE(?but29)
BUTTON,AT(120,20,10,10),USE(?but2a)
BUTTON,AT(130,20,10,10),USE(?but2b)
BUTTON,AT(140,20,10,10),USE(?but2c)
BUTTON,AT(30,30,10,10),USE(?but31)
BUTTON,AT(40,30,10,10),USE(?but32)
BUTTON,AT(50,30,10,10),USE(?but33)
BUTTON,AT(60,30,10,10),USE(?but34)
BUTTON,AT(70,30,10,10),USE(?but35)
BUTTON,AT(80,30,10,10),USE(?but36)
BUTTON,AT(90,30,10,10),USE(?but37)
BUTTON,AT(100,30,10,10),USE(?but38)
BUTTON,AT(110,30,10,10),USE(?but39)
BUTTON,AT(120,30,10,10),USE(?but3a)
BUTTON,AT(130,30,10,10),USE(?but3b)
BUTTON,AT(140,30,10,10),USE(?but3c)
BUTTON,AT(30,40,10,10),USE(?but41)
BUTTON,AT(40,40,10,10),USE(?but42)
BUTTON,AT(50,40,10,10),USE(?but43)
BUTTON,AT(60,40,10,10),USE(?but44)
BUTTON,AT(70,40,10,10),USE(?but45)
BUTTON,AT(80,40,10,10),USE(?but46)
BUTTON,AT(90,40,10,10),USE(?but47)
BUTTON,AT(100,40,10,10),USE(?but48)
BUTTON,AT(110,40,10,10),USE(?but49)
BUTTON,AT(120,40,10,10),USE(?but4a)
BUTTON,AT(130,40,10,10),USE(?but4b)
BUTTON,AT(140,40,10,10),USE(?but4c)
BUTTON,AT(30,50,10,10),USE(?but51)
BUTTON,AT(40,50,10,10),USE(?but52)
BUTTON,AT(50,50,10,10),USE(?but53)
BUTTON,AT(60,50,10,10),USE(?but54)
BUTTON,AT(70,50,10,10),USE(?but55)
BUTTON,AT(80,50,10,10),USE(?but56)
BUTTON,AT(90,50,10,10),USE(?but57)
BUTTON,AT(100,50,10,10),USE(?but58)
BUTTON,AT(110,50,10,10),USE(?but59)
BUTTON,AT(120,50,10,10),USE(?but5a)
BUTTON,AT(130,50,10,10),USE(?but5b)
BUTTON,AT(140,50,10,10),USE(?but5c)
BUTTON,AT(30,60,10,10),USE(?but61)
BUTTON,AT(40,60,10,10),USE(?but62)
BUTTON,AT(50,60,10,10),USE(?but63)
BUTTON,AT(60,60,10,10),USE(?but64)
BUTTON,AT(70,60,10,10),USE(?but65)
BUTTON,AT(80,60,10,10),USE(?but66)
BUTTON,AT(90,60,10,10),USE(?but67)
BUTTON,AT(100,60,10,10),USE(?but68)
BUTTON,AT(110,60,10,10),USE(?but69)
BUTTON,AT(120,60,10,10),USE(?but6a)
BUTTON,AT(130,60,10,10),USE(?but6b)
BUTTON,AT(140,60,10,10),USE(?but6c)
BUTTON,AT(30,70,10,10),USE(?but111)
BUTTON,AT(40,70,10,10),USE(?but121)
BUTTON,AT(50,70,10,10),USE(?but131)
BUTTON,AT(60,70,10,10),USE(?but141)
BUTTON,AT(70,70,10,10),USE(?but151)
BUTTON,AT(80,70,10,10),USE(?but161)
BUTTON,AT(90,70,10,10),USE(?but171)
BUTTON,AT(100,70,10,10),USE(?but181)
BUTTON,AT(110,70,10,10),USE(?but191)
BUTTON,AT(120,70,10,10),USE(?but1a1)
BUTTON,AT(130,70,10,10),USE(?but1b1)
BUTTON,AT(140,70,10,10),USE(?but1c1)
BUTTON,AT(30,80,10,10),USE(?but211)
BUTTON,AT(40,80,10,10),USE(?but221)
BUTTON,AT(50,80,10,10),USE(?but231)
BUTTON,AT(60,80,10,10),USE(?but241)
BUTTON,AT(70,80,10,10),USE(?but251)
BUTTON,AT(80,80,10,10),USE(?but261)
BUTTON,AT(90,80,10,10),USE(?but271)
BUTTON,AT(100,80,10,10),USE(?but281)
BUTTON,AT(110,80,10,10),USE(?but291)
BUTTON,AT(120,80,10,10),USE(?but2a1)
BUTTON,AT(130,80,10,10),USE(?but2b1)
BUTTON,AT(140,80,10,10),USE(?but2c1)
BUTTON,AT(30,90,10,10),USE(?but311)
BUTTON,AT(40,90,10,10),USE(?but321)
BUTTON,AT(50,90,10,10),USE(?but331)
BUTTON,AT(60,90,10,10),USE(?but341)
BUTTON,AT(70,90,10,10),USE(?but351)
BUTTON,AT(80,90,10,10),USE(?but361)
BUTTON,AT(90,90,10,10),USE(?but371)
BUTTON,AT(100,90,10,10),USE(?but381)
BUTTON,AT(110,90,10,10),USE(?but391)
BUTTON,AT(120,90,10,10),USE(?but3a1)
BUTTON,AT(130,90,10,10),USE(?but3b1)
BUTTON,AT(140,90,10,10),USE(?but3c1)
BUTTON,AT(30,100,10,10),USE(?but411)
BUTTON,AT(40,100,10,10),USE(?but421)
BUTTON,AT(50,100,10,10),USE(?but431)
BUTTON,AT(60,100,10,10),USE(?but441)
BUTTON,AT(70,100,10,10),USE(?but451)
BUTTON,AT(80,100,10,10),USE(?but461)
BUTTON,AT(90,100,10,10),USE(?but471)
BUTTON,AT(100,100,10,10),USE(?but481)
BUTTON,AT(110,100,10,10),USE(?but491)
BUTTON,AT(120,100,10,10),USE(?but4a1)
BUTTON,AT(130,100,10,10),USE(?but4b1)
BUTTON,AT(140,100,10,10),USE(?but4c1)
BUTTON,AT(30,110,10,10),USE(?but511)
BUTTON,AT(40,110,10,10),USE(?but521)
BUTTON,AT(50,110,10,10),USE(?but531)
BUTTON,AT(60,110,10,10),USE(?but541)
BUTTON,AT(70,110,10,10),USE(?but551)
BUTTON,AT(80,110,10,10),USE(?but561)
BUTTON,AT(90,110,10,10),USE(?but571)
BUTTON,AT(100,110,10,10),USE(?but581)
BUTTON,AT(110,110,10,10),USE(?but591)
BUTTON,AT(120,110,10,10),USE(?but5a1)
BUTTON,AT(130,110,10,10),USE(?but5b1)
BUTTON,AT(140,110,10,10),USE(?but5c1)
BUTTON,AT(30,120,10,10),USE(?but611)
BUTTON,AT(40,120,10,10),USE(?but621)
BUTTON,AT(50,120,10,10),USE(?but631)
BUTTON,AT(60,120,10,10),USE(?but641)
BUTTON,AT(70,120,10,10),USE(?but651)
BUTTON,AT(80,120,10,10),USE(?but661)
BUTTON,AT(90,120,10,10),USE(?but671)
BUTTON,AT(100,120,10,10),USE(?but681)
BUTTON,AT(110,120,10,10),USE(?but691)
BUTTON,AT(120,120,10,10),USE(?but6a1)
BUTTON,AT(130,120,10,10),USE(?but6b1)
BUTTON,AT(140,120,10,10),USE(?but6c1)
STRING(@N5),AT(30,140,20,10),FONT('Helv',10,0FFH,),USE(counts[1],1001)
STRING(@N5),AT(110,140,20,10),FONT('Helv',10,0FF00H,),USE(counts[2],1002)
STRING(@N5),AT(70,140,20,10),FONT('Helv',10,0FF0000H,),USE(counts[3],1003)
STRING(@N5),AT(150,140,20,10),FONT('Helv',10,0FFFFH,),USE(counts[4],1004)
STRING(@N5),AT(30,140,20,10),FONT('Helv',10,0FFH,),USE(scores[1],2001)
STRING(@N5),AT(110,140,20,10),FONT('Helv',10,0FF00H,),USE(scores[2],2002)
STRING(@N5),AT(70,140,20,10),FONT('Helv',10,0FF0000H,),USE(scores[3],2003)
STRING(@N5),AT(150,140,20,10),FONT('Helv',10,0FFFFH,),USE(scores[4],2004)
BOX,AT(29,139,22,12),USE(?box1,3001)
BOX,AT(109,139,22,12),USE(?box2,3002)
BOX,AT(69,139,22,12),USE(?box3,3003)
BOX,AT(149,139,22,12),USE(?box4,3004)
END
CODE
HELP('DOMIN')
width = 6;
boardwidth = '6x6'
wp[1] = SHuman
playname[1] = 'Human'
wp[2] = SDefence
playname[2] = 'Defensive'
wp[3] = 0
playname[3] = 'None'
wp[4] = 0
playname[4] = 'None'
OPEN(scr)
setsize()
init()
setcursors()
ACCEPT
CASE EVENT()
OF EVENT:CloseWindow
OROF EVENT:CloseDown
IF asknewgame()
BREAK
ELSE
CYCLE
END
OF EVENT:Accepted
CASE ACCEPTED()
OF ?exit
IF asknewgame()
BREAK
END
OF ?new
IF asknewgame()
init();
END
OF ?options
IF asknewgame()
getoptions()
init();
END
OF ?helpcontents
HELP()
OF ?about
aboutbox()
ELSE
yp = ((ACCEPTED()-1) / maxwidth)+1
xp = ((ACCEPTED()-1) % maxwidth)+1
IF nplaying>1 AND canadd(xp,yp,nextgo) THEN
gameinprogress = 1
counts[nextgo] = counts[nextgo] + 1
DISPLAY(1000+nextgo)
addc(xp,yp,nextgo)
LOOP
HIDE(3000+nextgo,3000+nextgo)
nextgo = nextgo + 1
IF nextgo > mplayers THEN nextgo = 1.
IF counts[nextgo] THEN
UNHIDE(3000+nextgo,3000+nextgo)
IF wp[nextgo] = SHuman THEN
setcursors()
BREAK
END
positional(xp,yp,nextgo)
IF canadd(xp,yp,nextgo) THEN
DISPLAY(1000+nextgo)
counts[nextgo] = counts[nextgo] + 1
addc(xp,yp,nextgo)
END
IF gameinprogress = 0 THEN BREAK.
END
END
ELSE
BEEP
END
END
END
END
CLOSE(scr)
showp PROCEDURE(x,y)
st STRING(20),AUTO
count BYTE
CODE
IF t[x,y] THEN
st = '~plxn.ico'
st[4] = bshift(t[x,y],-3) - 1
count = t[x,y] % 8
IF count>3 THEN
st[5] = 4
ELSE
st[5] = count
END
ELSE
st = '~empty.ico'
END
((y-1)*maxwidth + x){PROP:Icon} = st
getoptions PROCEDURE
optscreen window('Domination'), at(,,150,150), DOUBLE,GRAY,CENTER,HLP('~Options')
string('Select player types:'),AT(10,20,150,10)
prompt('Player &1:'), at(10,40,50,10),FONT('Helv',10,00000FFH)
LIST, FROM('None|Human|Defensive|Homicidal|Regicidal|Drifter'), |
DROP(6), USE(playname[1],1),AT(60,40,50,10),FONT('Helv',10,00000FFH)
prompt('Player &2:'), at(10,55,50,10),FONT('Helv',10,000FF00H)
LIST, FROM('None|Human|Defensive|Homicidal|Regicidal|Drifter'), |
DROP(6), USE(playname[2],2),AT(60,55,50,10),FONT('Helv',10,000FF00H)
prompt('Player &3:'), at(10,70,50,10),FONT('Helv',10,0FF0000H)
LIST, FROM('None|Human|Defensive|Homicidal|Regicidal|Drifter'), |
DROP(6), USE(playname[3],3),AT(60,70,50,10),FONT('Helv',10,0FF0000H)
prompt('Player &4:'), at(10,85,50,10),FONT('Helv',10,000FFFFH)
LIST, FROM('None|Human|Defensive|Homicidal|Regicidal|Drifter'), |
DROP(6), USE(playname[4],4),AT(60,85,50,10),FONT('Helv',10,000FFFFH)
prompt('&Board width'), at(10,100,50,10)
LIST, FROM('6x6|8x8|10x10|12x12'), DROP(4), USE(boardwidth),AT(60,100,50,10)
button('&Ok'),AT(80,115,50,12),USE(?optok),DEFAULT
END
changewidth SHORT
x SHORT, AUTO
y SHORT, AUTO
w SHORT, AUTO
h SHORT, AUTO
CODE
open(optscreen)
ACCEPT
IF EVENT() = EVENT:Accepted
CASE ACCEPTED()
OF 1
OROF 2
OROF 3
OROF 4
wp[ACCEPTED()] = CHOICE()-1
OF ?boardwidth
CASE CHOICE()
OF 1
width = 6
OF 2
width = 8
OF 3
width = 10
OF 4
width = 12
END
changewidth = 1
OF ?optok
BREAK
END END
END
CLOSE(optscreen)
IF changewidth THEN
setsize()
END
setsize PROCEDURE
space SHORT
ypos SHORT
CODE
space = width*10 / 3
ypos = 40+width*10
SetPosition(1001, 20, ypos, 18, 10)
SetPosition(1003, 20+space, ypos, 18, 10)
SetPosition(1002, 20+space*3, ypos, 18, 10)
SetPosition(1004, 20+space*2, ypos, 18, 10)
ypos = ypos+12
SetPosition(2001, 20, ypos, 18, 10)
SetPosition(2003, 20+space, ypos, 18, 10)
SetPosition(2002, 20+space*3, ypos, 18, 10)
SetPosition(2004, 20+space*2, ypos, 18, 10)
ypos = ypos-13
SetPosition(3001, 19, ypos, 20, 24)
SetPosition(3003, 19+space, ypos, 20, 24)
SetPosition(3002, 19+space*3, ypos, 20, 24)
SetPosition(3004, 19+space*2, ypos, 20, 24)
LOOP i# = 1 TO maxwidth
LOOP j# = 1 TO maxwidth
feq# = (j#-1)*maxwidth + i#
IF i#>width OR j#>width THEN
HIDE(feq#, feq#)
ELSE
t[i#,j#] = 0
showp(i#,j#)
UNHIDE(feq#, feq#)
END
END
END
SetPosition(0,,,60+width*10, 80+width*10)
asknewgame FUNCTION
askscreen WINDOW('Domination'),AT(,,90,50),DOUBLE,GRAY,CENTER
STRING('Abort current game?'),AT(0,10,90,10),CENTER
BUTTON('&No'),AT(10,30,30,12),USE(?cancel,1)
BUTTON('&Yes'),AT(50,30,30,12),USE(?ok,2),DEFAULT
END
CODE
IF gameinprogress=0 THEN RETURN 1.
OPEN(askscreen)
ret# = 0
ACCEPT
IF EVENT()=EVENT:accepted
ret# = ACCEPTED()-1
BREAK
END
END
CLOSE(askscreen)
RETURN ret#
aboutbox PROCEDURE
aboutscreen WINDOW('About Domination'),AT(,,100,50),CENTER,GRAY,DOUBLE
STRING('Domination version 1END0'),AT(0,10,100,10),CENTER
BUTTON('&Ok'),AT(36,28,30,12),USE(?ok),DEFAULT
END
CODE
open(aboutscreen)
ACCEPT
IF Event()=EVENT:accepted
BREAK
END
END
gameover PROCEDURE
overscreen window('Domination'), at(,,90,50),DOUBLE, GRAY, CENTER
string('Game over!'),AT(0,10,90,10),CENTER
button('&Ok'),AT(30,30,30,12),USE(?overok)
END
x SHORT, AUTO
y SHORT, AUTO
w SHORT, AUTO
h SHORT, AUTO
CODE
gameinprogress = 0
open(overscreen)
ret# = 0
ACCEPT
IF EVENT()=EVENT:accepted
BREAK
END
END
CLOSE(overscreen)
setcursors PROCEDURE
CODE
RETURN
LOOP i# = 1 TO width
LOOP j# = 1 TO width
feq# = (j#-1)*maxwidth + i#
IF canadd(i#,j#,nextgo)
feq#{PROP:Cursor} = '~allowENDcur'
ELSE
feq#{PROP:Cursor} = '~disallowENDcur'
END
END
END
init PROCEDURE
CODE
gameinprogress = 0
nextgo = 1
LOOP i# = 1 TO width
LOOP j# = 1 TO width
t[i#,j#] = 0
END
END
LOOP i#=1 to mplayers
scores[i#] = 0
counts[i#] = 0
END
HIDE(1001,1000+mplayers);
HIDE(2001,2000+mplayers);
HIDE(3002,3000+mplayers);
UNHIDE(3001,3001);
nplaying = 0
IF wp[1] THEN
t[1,1] = 9
counts[1]=1
nplaying = nplaying + 1
UNHIDE(1001,1001)
UNHIDE(2001,2001)
END
IF wp[2] THEN
t[width,width] = 17
counts[2]=1
nplaying = nplaying + 1
UNHIDE(1002,1002)
UNHIDE(2002,2002)
END
IF wp[3] THEN
t[1,width] = 25
counts[3]=1
nplaying = nplaying + 1
UNHIDE(1003,1003)
UNHIDE(2003,2003)
END
IF wp[4] THEN
t[width,1] = 33
counts[4]=1
nplaying = nplaying + 1
UNHIDE(1004,1004)
UNHIDE(2004,2004)
END
LOOP i# = 1 TO width
LOOP j# = 1 TO width
showp(i#,j#)
END
END
addc PROCEDURE(x,y,player)
CODE
IF x < 1 OR x > width OR y < 1 OR y > width THEN RETURN.
IF nplaying < 2 THEN
RETURN
END
scores[player] += 1
IF (scores[player]%10) = 0 THEN
DISPLAY(2000+player)
END
count# = t[x,y] % 8
oldp# = bshift(t[x,y],-3)
IF oldp# and oldp# <> player THEN
counts[player] = counts[player]+count#
counts[oldp#] = counts[oldp#]-count#
IF counts[oldp#] = 0 THEN
nplaying = nplaying - 1
END
DISPLAY(1000+oldp#)
DISPLAY(1000+player)
END
count# = count# + 1
t[x,y] = player*8 + count#
showp(x,y)
IF nplaying < 2 THEN
gameover()
RETURN
END
cap#=capacity(x,y)
IF count# >= cap# THEN
t[x,y] = t[x,y]-cap#
IF count#=cap# THEN t[x,y]=0.
showp(x,y)
addc(x-1,y,player)
addc(x,y-1,player)
addc(x,y+1,player)
addc(x+1,y,player)
END
canadd FUNCTION(x,y,player)
CODE
IF x < 1 OR x > width OR y < 1 OR y > width THEN
RETURN 0 ! Out OF bounds
END
IF t[x,y] THEN
IF bshift(t[x,y],-3) <> player THEN
RETURN 0 ! Occupied by the enemy
ELSE
RETURN 1
END
END
IF x > 1 and bshift(t[x-1,y],-3) = player THEN
RETURN 1
END
IF y > 1 and bshift(t[x,y-1],-3) = player THEN
RETURN 1
END
IF x < width and bshift(t[x+1,y],-3) = player THEN
RETURN 1
END
IF y < width and bshift(t[x,y+1],-3) = player THEN
RETURN 1
END
RETURN 0
capacity FUNCTION(x,y)
c BYTE
CODE
IF x > 1 THEN
c += 1
END
IF x < width THEN
c += 1
END
IF y > 1 THEN
c += 1
END
IF y < width THEN
c += 1
END
RETURN c
omit('═╝')
╔═══════════════════════════════════════════════════════════════════════════╗
║ ║
║ This routine computes the 'currently occupied quarter' for each player. ║
║ Then depending on the active player strategy it selects which corner ║
║ the search should be aiming towards. The actual search mechanism is ║
║ performed elsewhere ║
║ Result numbering : 1 2 ║
║ 3 4 ║
║ ║
║ Defensive Strategy : Blow up something as near to your own corner ║
║ as possibleEND Otherwise stockpile ║
║ ║
║ Drifter Strategy : Blow up something as far from your own corner ║
║ as possible ║
║ ║
║ Homicidal Strategy : Go for any available human ║
║ ║
║ Regicidal Strategy : Go for any available computer ║
║ ║
╚═══════════════════════════════════════════════════════════════════════════╝
locate_target FUNCTION(player)
ccounts BYTE,DIM(4),DIM(mplayers)
cp BYTE
res BYTE
CODE
LOOP i# = 1 TO width
IF i# < 7 THEN cp = 1 ELSE cp = 2.
LOOP j# = 1 TO width
IF j# = 7 THEN cp += 2.
IF t[i#,j#] THEN ccounts[cp,bshift(t[i#,j#],-3)] += 1.
. .
IF wp[player] = SHomicidal THEN
cp = 0
LOOP i# = 1 TO mplayers
IF wp[i#] = SHuman THEN
LOOP j# = 1 TO 4
IF ccounts[j#,i#] > cp THEN
cp = ccounts[j#,i#]
res = j#
END
END
END
END
IF res = 0 THEN wp[player] = SRegicidal.
END
IF wp[player] = SRegicidal THEN
cp = 0
LOOP i# = 1 TO mplayers
IF wp[i#] > SHuman AND i# <> player THEN
LOOP j# = 1 to 4
IF ccounts[j#,i#] > cp THEN
cp = ccounts[j#,i#]
res = j#
END
END
END
END
IF res = 0 THEN wp[player] = SDrifter END
END
IF res = 0 THEN
cp = 0
LOOP j# = 1 TO 4
IF ccounts[j#,player] > cp THEN
cp = ccounts[j#,player]
res = j#
END
END
IF wp[player] = SDrifter THEN res = 5 - res.
END
RETURN res
positional PROCEDURE(x,y,player)
xbv BYTE(255)
near BYTE(255)
xs SHORT(1)
ys SHORT(1)
ta BYTE
CODE
x = 0
y = 0
ta = locate_target(player)
CASE ta
OF 2
xs = -1
OF 3
ys = -1
OF 4
xs = -1
ys = -1
END
LOOP i#= 1 to width
LOOP j#= 1 to width
IF canadd(i#,j#,player) THEN
cij# = capacity(i#,j#)
!cb# = ( cij# - t[i#,j#] % 8 ) * 4 + cij#
cb# = cij# - t[i#,j#] % 8
IF xs > 0 THEN di# = i# ELSE di# = 13 - i# END
di# *= 10
IF ys > 0 THEN di# += j# ELSE di# += 13 - j#.
IF cb# < xbv OR cb#= xbv AND di# < near THEN
xbv = cb#
near = di#
x = i#
y = j#
END
END
END
END